<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp"%>
<link rel="stylesheet" type="text/css" href="<c:url value='/ui/themes/fullcalendar.css' />" />
<script type="text/javascript" src="<c:url value='/ui/fullcalendar.js' />"></script>
<script type="text/javascript" src="<c:url value='/ui/jquery-ui-1.8.9.custom.min.js' />"></script>
<script type="text/javascript">
$(function(){
	var date = new Date();
    var d = date.getDate();
    var m = date.getMonth();
    var y = date.getFullYear();
    $('#calendarDiv').fullCalendar({
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay'
        },
        titleFormat: {
            month: 'yyyy MMMM',
            week: "yyyy, MMM d[ yyyy]{ '&#8212;'[ MMM] d}",
            day: 'yyyy, MMM d, dddd'
        },
        monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
        monthNamesShort: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
        dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
        dayNamesShort: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
        buttonText: {
            today: '今天',
            month: '月',
            week: '周',
            day: '天'
        },
		timeFormat: {
			'': 'HH:mm' // 事件上显示时间格式
		},
        aspectRatio: 2.5,//宽高比
		startParam: 'beginTime',
		endParam: 'endTime',
        editable: false,
        eventClick: eventClickFun,
		selectable: true,
        select: selectFun,
        events: ctx + '/pof/Calendar!findCalendar.action'
    });
    
    //点击日期方法
    function selectFun(start, end, allDay) {
    	end.setSeconds(end.getSeconds() + 3600 * 24 - 1);
    	CQOA.load('operationDiv',ctx+'/pof/Calendar!operate.action',{},function(){
    		$('#calendarDiv').fullCalendar('unselect');
    		CQOA.hideDiv('mainDiv');
			CQOA.showDiv('operationDiv');
    		$('#isAllDay').attr('checked', allDay);
    		$('#beginTime').val(start.pattern('yyyy-MM-dd hh:mm:ss'));
			$('#endTime').val(end.pattern('yyyy-MM-dd hh:mm:ss'));
		});
    	
    }

    //点击日程方法
    function eventClickFun(event) {
    	console.log("click");
    	if (event.isInitiator) {
    		CQOA.load("operationDiv", ctx + '/pof/Calendar!operate.action', {
    			'entity.sid': event.id
    		}, function() {
    			$('#calendarDiv').fullCalendar('unselect');
    			CQOA.hideDiv('mainDiv');
    			CQOA.showDiv('operationDiv');
    			$('#isAllDay').attr('checked', event.allDay);
    			$('#beginTime').val(event.start.pattern('yyyy-MM-dd hh:mm:ss'));
    			$('#endTime').val(event.end.pattern('yyyy-MM-dd hh:mm:ss'));
    		});
    	} else {
    		CQOA.load("operationDiv", ctx + '/pof/Calendar!detail.action', {
    			'entity.sid': event.id
    		}, function() {
    			$('#calendarDiv').fullCalendar('unselect');
    			CQOA.hideDiv('mainDiv');
    			CQOA.showDiv('operationDiv');
    		});
    	}
    }
});

var isChecked = false;

//返回
function function_return() {
	CQOA.hideDiv('operationDiv');
	CQOA.showDiv('mainDiv');
    $('#calendarDiv').fullCalendar('refetchEvents');//加载日程
};


var function_isAllDay = function(o) {
    if (o.checked) {
        $('#beginTime').datetimebox('setValue', $('#beginTime').datetimebox('getValue').split(' ')[0] + ' 00:00:00');
        $('#endTime').datetimebox('setValue', $('#endTime').datetimebox('getValue').split(' ')[0] + ' 23:59:59');
    }
};

var function_isSendSms = function(o){
	if(o.checked){
		$('#smsTime').removeAttr('disabled',false);
		$('#isSendSms').attr('checked',true);
		isChecked  = true;
	}
	else{
		$('#smsTime').val('');
		$('#smsTime').attr('disabled',true);
		isChecked = false;
	}
};
        
</script>
<div id="mainDiv" class="easyui-panel" border="false" fit="true" style="position:relative;left:0;top:0;overflow:scroll">
	<div id="easyui-title" style="display:none">
            	个人日程
	</div>
	<div id="calendarDiv" style="width:95%">
	</div>
</div>
<div id="operationDiv" class="easyui-panel" style="display:none;" fit="true" border="false"></div>

